namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Drawing;

    public class FormDmNhDtLister : FormListLister
    {
        private IContainer components;

        public FormDmNhDtLister()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x2bd, 0x10a);
            base.LocalFieldCount = 0;
            base.LocalFieldName = "MA_NH_DT";
            base.LocalTableName = "DMNHDT";
            base.Name = "FormDmNhDtLister";
            base.OrderFieldNames = "STT_NH_DT";
            base.RefreshAfterChanged = true;
            base.SortByColumn = false;
            this.Text = "Danh mục nhóm đối tượng";
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override bool OnAdd()
        {
            base.LocalFormEditor = new FormDmNhDtEditor();
            return base.OnAdd();
        }

        public override bool OnEdit()
        {
            base.LocalFormEditor = new FormDmNhDtEditor();
            return base.OnEdit();
        }

        public override void OnFillData()
        {
            object[][] objArray = new object[5][];
            object[] objArray2 = new object[4];
            objArray2[0] = "Ma_Nh_Dt";
            objArray2[1] = "Mã nhóm";
            objArray2[2] = "C";
            objArray[0] = objArray2;
            object[] objArray3 = new object[4];
            objArray3[0] = "Ten_Nh_Dt";
            objArray3[1] = "Tên nhóm đối tượng";
            objArray3[2] = "C";
            objArray[1] = objArray3;
            object[] objArray4 = new object[4];
            objArray4[0] = "Nh_Me_Dt";
            objArray4[1] = "Nhóm mẹ";
            objArray4[2] = "C";
            objArray[2] = objArray4;
            objArray[3] = new object[] { "Bac_Nh_Dt", "Cấp", "N", AppInstance.TextNumericFormat.None };
            object[] objArray6 = new object[4];
            objArray6[0] = "Nh_Cuoi_Dt";
            objArray6[1] = "Nhóm cuối";
            objArray6[2] = "C";
            objArray[4] = objArray6;
            base.ColNames = objArray;
            base.OnFillData();
        }

        public override void OnRefresh()
        {
            base.LocalDataSet = new DmNhDtDataAccess().GetDataSet();
            base.OnRefresh();
        }

        protected override void OnShowChildForm()
        {
            if (this.IsContainChilds)
            {
                FormDmDtLister lister = new FormDmDtLister(this);
                lister.CurrentCode = base.ChildItemCode;
                base.ChildFormLister = lister;
                lister.FirstFilter = base.ChildFirstFilter;
                lister.ShowDialog();
                if (!lister.EscapeKeyHook)
                {
                    base.Close();
                }
            }
        }

        protected override void OnShowChildForm(string ps_ChildItemCode)
        {
            FormDmDtLister lister = new FormDmDtLister(this);
            lister.CurrentCode = ps_ChildItemCode;
            if (lister.LocalCurrentRow != null)
            {
                base.ChildFormLister = lister;
                lister.FirstFilter = base.ChildFirstFilter;
                lister.ShowDialog();
            }
        }

        protected override bool IsContainChilds
        {
            get
            {
                return ((base.LocalCurrentRow != null) && base.LocalCurrentRow["Nh_Cuoi_Dt"].ToString().Equals("C"));
            }
        }
    }
}

